package com.jackchen.common;

import org.springframework.beans.factory.config.BeanPostProcessor;
import org.springframework.beans.BeansException;

import org.apache.log4j.Logger;

/*
 * @Author:
 * @Description:此方法为调试类，方便观察Spring初始化bean的运行
 */
public class DebugSpringBean implements BeanPostProcessor {  
	
	private static final Logger log = Logger.getLogger(DebugSpringBean.class);
	  
    // simply return the instantiated bean as-is  
    public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException {  
        return bean; // we could potentially return any object reference here...  
    }  
    //在创建bean后输出bean的信�? 
    public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException {  
       // System.out.println("Bean '" + beanName + "' created : " + bean.toString());  
    	log.info("---------------------------------------------------------------------");
    	log.info(beanName+":初始化完毕");
    	log.info("---------------------------------------------------------------------");
    	return bean;  
    }  
}  